//
//  ShipmentReportVC.m
//  ProjectforHDX
//
//  Created by lzg on 2017/8/10.
//  Copyright © 2017年 H.DX. All rights reserved.
//

#import "ShipmentReportVC.h"
#import "MainVC.h"
#import "StockPopVIewController.h"
#import "WarehouseTotalVC.h"
#import "WarehousePlateVC.h"
#import "SerialNumberVC.h"

@interface ShipmentReportVC ()<StockPopViewDelegate,UIScrollViewDelegate> {
    NSArray *conditionArr;
    UIView *queryView;
    UIDatePicker *datePicker;
    UIToolbar *toolBar;
    UIButton *startBut;
    UIButton *endBut;
    UIButton *warehouseBut;
    NSInteger teger;
    StockPopVIewController *_popView;
    BOOL showPop;
    NSMutableArray *stockArr;
    NSInteger dropDown;
    NSMutableDictionary *stockDic;
    NSString *startStr;
    NSString *endStr;
    NSString *customerStr;
    
    
    UIButton *customerText; //客户
    UITextField *attachmentNameBut; //备件名称
    UITextField *attachmentBut;  //备件编号
    UITextField *serialNumberBut; //序列号
    
    NSMutableArray *customerArr;
    
}
@property (nonatomic, strong) UIView *maskView;
@property (nonatomic, strong) UIView *coverView;
@end

@implementation ShipmentReportVC

- (void)viewDidLoad {
    [super viewDidLoad];
    customerArr = [NSMutableArray array];
    stockArr = [NSMutableArray array];
    stockDic = [NSMutableDictionary dictionary];
    startStr = @"";
    endStr = @"";
    [self headView];
    [self queryPage];
    [self stockInquiry];
    [self customerName];
}

- (void)headView {
    UIView *headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.height, 64)];
    [headView setBackgroundColor:[UtilCheck hexStringToColor:@"#1A57BE" alpha:1]];
    [self.view addSubview:headView];
    
    UIButton *backBtn = [[UIButton alloc]init];
    [backBtn setFrame:CGRectMake(0, 20, 44, 44)];
    [backBtn addTarget:self action:@selector(backView) forControlEvents:UIControlEventTouchUpInside];
    backBtn.backgroundColor = [UtilCheck hexStringToColor:@"#1A57BE" alpha:1.0];
    [backBtn setImage:[UIImage imageNamed:@"ShipmentReportVC返回"] forState:UIControlStateNormal];
    [self.view addSubview:backBtn];
    
    UILabel *headLable = [[UILabel alloc]initWithFrame:CGRectMake(0, 20, self.view.height, 44)];
    headLable.text = [UtilCheck language:@"main.shipmentReport"];
    headLable.textColor = [UIColor whiteColor];
    [headLable setFont:[UIFont systemFontOfSize:20]];
    headLable.textAlignment = UITextAlignmentCenter;
    [headView addSubview:headLable];
}
- (void)queryPage {
    UIScrollView *scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 64, self.view.height, self.view.width-64)];
    [scrollView setBackgroundColor:[UIColor whiteColor]];
    [scrollView setDelegate:self];
    [self.view addSubview:scrollView];
    queryView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.height, self.view.width-64)];
    [queryView setBackgroundColor:[UIColor whiteColor]];
    [scrollView addSubview:queryView];
    
    
    UILabel *starTimeLable = [[UILabel alloc]initWithFrame:CGRectMake(30, 15, 90, 44)];
    NSString *contentStr = [NSString stringWithFormat:@"*%@",[UtilCheck language:@"setting.startTime"]];
    starTimeLable.numberOfLines = 0;
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc]initWithString:contentStr];
    //设置：在0-3个单位长度内的内容显示成红色
    [str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 1)];
    starTimeLable.attributedText = str;
    [queryView addSubview:starTimeLable];
    startBut = [[UIButton alloc]initWithFrame:CGRectMake(starTimeLable.width+starTimeLable.origin.x, starTimeLable.origin.y, (self.view.height/2)-starTimeLable.width-60, 44)];
    [startBut.layer setMasksToBounds:YES];
    [startBut.layer setCornerRadius:5];
    [startBut.layer setBorderColor:[UIColor blackColor].CGColor];
    startBut.layer.borderWidth= 0.5f;
    [startBut addTarget:self action:@selector(startBut) forControlEvents:(UIControlEventTouchUpInside)];
    [queryView addSubview:startBut];
    
    UILabel *endTimeLable = [[UILabel alloc]initWithFrame:CGRectMake ((self.view.height/2)+30, 15, 90, 44)];
    NSString *endContentStr = [NSString stringWithFormat:@"*%@",[UtilCheck language:@"setting.endTime"]];
    endTimeLable.numberOfLines = 0;
    NSMutableAttributedString *endStr = [[NSMutableAttributedString alloc]initWithString:endContentStr];
    //设置：在0-3个单位长度内的内容显示成红色
    [endStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 1)];
    endTimeLable.attributedText = endStr;
    [queryView addSubview:endTimeLable];
    endBut = [[UIButton alloc]initWithFrame:CGRectMake(endTimeLable.width+endTimeLable.origin.x, endTimeLable.origin.y, (self.view.height/2)-endTimeLable.width-60, 44)];
    [endBut.layer setMasksToBounds:YES];
    [endBut.layer setCornerRadius:5];
    [endBut.layer setBorderColor:[UIColor blackColor].CGColor];
    endBut.layer.borderWidth= 0.5f;
    [endBut addTarget:self action:@selector(endBut) forControlEvents:(UIControlEventTouchUpInside)];
    [queryView addSubview:endBut];
    
    UILabel *warehouseLable = [[UILabel alloc]initWithFrame:CGRectMake(starTimeLable.origin.x, 2 * starTimeLable.origin.y+starTimeLable.height, starTimeLable.width, starTimeLable.height)];
    warehouseLable.text = [UtilCheck language:@"setting.warehouse"];
    warehouseLable.numberOfLines = 0;
    [queryView addSubview:warehouseLable];
    warehouseBut = [[UIButton alloc]initWithFrame:CGRectMake(warehouseLable.width+warehouseLable.origin.x, warehouseLable.origin.y, (self.view.height/2)-warehouseLable.width-60, 44)];
    [warehouseBut.layer setMasksToBounds:YES];
    [warehouseBut.layer setCornerRadius:5];
    [warehouseBut.layer setBorderColor:[UIColor blackColor].CGColor];
    warehouseBut.layer.borderWidth= 0.5f;
    [warehouseBut setImage:BDFILEIMAGENAEM(@"Home/btn_dropGray") forState:UIControlStateNormal];
    warehouseBut.imageEdgeInsets = UIEdgeInsetsMake(10, (self.view.height/2)-warehouseLable.width-75, 10, 0);
    [warehouseBut addTarget:self action:@selector(warehouseBut:) forControlEvents:(UIControlEventTouchUpInside)];
    [queryView addSubview:warehouseBut];
    
    UILabel *customerLable = [[UILabel alloc]initWithFrame:CGRectMake(endTimeLable.origin.x, 2 * endTimeLable.origin.y+endTimeLable.height, endTimeLable.width, endTimeLable.height)];
    customerLable.text = [UtilCheck language:@"order.customer"];
    customerLable.numberOfLines = 0;
    [queryView addSubview: customerLable];
    customerText = [[UIButton alloc]initWithFrame:CGRectMake(customerLable.width+customerLable.origin.x, customerLable.origin.y, (self.view.height/2)-customerLable.width-60, 44)];
    [customerText.layer setMasksToBounds:YES];
    [customerText.layer setCornerRadius:5];
    [customerText.layer setBorderColor:[UIColor blackColor].CGColor];
    customerText.layer.borderWidth= 0.5f;
    [customerText setImage:BDFILEIMAGENAEM(@"Home/btn_dropGray") forState:UIControlStateNormal];
    customerText.imageEdgeInsets = UIEdgeInsetsMake(10, (self.view.height/2)-warehouseLable.width-75, 10, 0);
    [customerText addTarget:self action:@selector(customerText:) forControlEvents:(UIControlEventTouchUpInside)];
    [queryView addSubview:customerText];
    
    UILabel *attachmentNameLable = [[UILabel alloc]initWithFrame:CGRectMake(warehouseLable.origin.x, starTimeLable.origin.y+ warehouseLable.origin.y+warehouseLable.height, warehouseLable.width, warehouseLable.height)];
    attachmentNameLable.text = [UtilCheck language:@"setting.sparePartName"];
    attachmentNameLable.numberOfLines = 0;
    [queryView addSubview:attachmentNameLable];
    attachmentNameBut = [[UITextField alloc]initWithFrame:CGRectMake(attachmentNameLable.width+attachmentNameLable.origin.x, attachmentNameLable.origin.y, (self.view.height/2)-attachmentNameLable.width-60, 44)];
    attachmentNameBut.textAlignment = UITextAlignmentCenter;
    [attachmentNameBut.layer setMasksToBounds:YES];
    [attachmentNameBut.layer setCornerRadius:5];
    [attachmentNameBut.layer setBorderColor:[UIColor blackColor].CGColor];
    attachmentNameBut.layer.borderWidth= 0.5f;
    [queryView addSubview:attachmentNameBut];
    
    UILabel *attachmentLable = [[UILabel alloc]initWithFrame:CGRectMake(customerLable.origin.x, starTimeLable.origin.y+ customerLable.origin.y+customerLable.height, customerLable.width, customerLable.height)];
    attachmentLable.text = [UtilCheck language:@"setting.sparePartNumber"];
    attachmentLable.numberOfLines = 0;
    [queryView addSubview:attachmentLable];
    attachmentBut = [[UITextField alloc]initWithFrame:CGRectMake(attachmentLable.width+attachmentLable.origin.x, attachmentLable.origin.y, (self.view.height/2)-attachmentLable.width-60, 44)];
    attachmentBut.textAlignment = UITextAlignmentCenter;
    [attachmentBut.layer setMasksToBounds:YES];
    [attachmentBut.layer setCornerRadius:5];
    [attachmentBut.layer setBorderColor:[UIColor blackColor].CGColor];
    attachmentBut.layer.borderWidth= 0.5f;
    [queryView addSubview:attachmentBut];
    
    UILabel *serialNumber = [[UILabel alloc]initWithFrame:CGRectMake(attachmentNameLable.origin.x, starTimeLable.origin.y+ attachmentNameLable.origin.y+attachmentNameLable.height, attachmentNameLable.width, attachmentNameLable.height)];
    serialNumber.text = [UtilCheck language:@"order.part.sn"];
    serialNumber.numberOfLines = 0;
    [queryView addSubview:serialNumber];
    serialNumberBut = [[UITextField alloc]initWithFrame:CGRectMake(serialNumber.width+serialNumber.origin.x, serialNumber.origin.y, (self.view.height/2)-serialNumber.width-60, 44)];
    serialNumberBut.textAlignment = UITextAlignmentCenter;
    [serialNumberBut.layer setMasksToBounds:YES];
    [serialNumberBut.layer setCornerRadius:5];
    [serialNumberBut.layer setBorderColor:[UIColor blackColor].CGColor];
    serialNumberBut.layer.borderWidth= 0.5f;
    [queryView addSubview:serialNumberBut];
    
    UIButton *queryBut = [[UIButton alloc]initWithFrame:CGRectMake((self.view.height/2)-90, starTimeLable.origin.y+ serialNumber.origin.y+serialNumber.height, 80, 44)];
    [queryBut setTitle:[UtilCheck language:@"setting.query"] forState:(UIControlStateNormal)];
    [queryBut setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    [queryBut setBackgroundColor:[UtilCheck hexStringToColor:@"#1A57BE" alpha:1]];
    [queryBut.layer setMasksToBounds:YES];
    [queryBut.layer setCornerRadius:5];
    [queryBut addTarget:self action:@selector(queryBut) forControlEvents:(UIControlEventTouchUpInside)];
    [queryView addSubview:queryBut];
//    empty
    UIButton *emptyBut = [[UIButton alloc]initWithFrame:CGRectMake((self.view.height/2)+10, starTimeLable.origin.y+ serialNumber.origin.y+serialNumber.height, 80, 44)];
    [emptyBut setTitle:[UtilCheck language:@"setting.empty"] forState:(UIControlStateNormal)];
    [emptyBut setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    [emptyBut setBackgroundColor:[UtilCheck hexStringToColor:@"#1A57BE" alpha:1]];
    [emptyBut.layer setMasksToBounds:YES];
    [emptyBut.layer setCornerRadius:5];
    [emptyBut addTarget:self action:@selector(emptyBut) forControlEvents:(UIControlEventTouchUpInside)];
    [queryView addSubview:emptyBut];
    
    if ((queryBut.origin.y+queryBut.height) > queryView.height) {
        queryView.height =queryBut.origin.y+queryBut.height+10;
    }
    scrollView.contentSize = CGSizeMake(self.view.height, queryView.height);
}
#pragma mark-按钮触发事件
//开始时间按钮
- (void)startBut {
    teger = 101;
    [self choiceTime];
}
//结束时间按钮
- (void)endBut {
    teger = 102;
    [self choiceTime];
}
- (void)emptyBut {
    startStr = @"";
    endStr = @"";
    customerStr = @"";
    [stockDic setValue:@"" forKey:@"storeCode"];
    [startBut setTitle:startStr forState:(UIControlStateNormal)];
    [endBut setTitle:endStr forState:(UIControlStateNormal)];
    [customerText setTitle:customerStr forState:(UIControlStateNormal)];
    [warehouseBut setTitle:@"" forState:(UIControlStateNormal)];
    attachmentNameBut.text = @"";
    attachmentBut.text = @"";
    serialNumberBut.text = @"";
}
//选择仓库名称
- (void)warehouseBut:(UIButton *)btn  {
    
    [UIView animateWithDuration:0.5 animations:^{
        [queryView setFrame:CGRectMake(0, -73+dropDown, self.view.width, self.view.height)];
    }];
    _coverView = [[UIView alloc]initWithFrame:self.view.frame];
    [_coverView setBackgroundColor:[THMangerTool getRZColor:250 green:250 blue:250 alpha:0.1]];
    [self.view addSubview:_coverView];
    if (!showPop) {
        StockPopVIewController *popView = [[StockPopVIewController alloc]init];
        popView.delegate = self;
        popView.teger = @"2";
        popView.popViewArr = stockArr;
        [popView.view setFrame:CGRectMake(warehouseBut.origin.x-5, 108, warehouseBut.width, 222)];
        [_coverView addSubview:popView.view];
        _popView = popView;
        showPop = YES;
    }
}
//选择客户名称
- (void)customerText:(UIButton *)btn  {
    
    [UIView animateWithDuration:0.5 animations:^{
        [queryView setFrame:CGRectMake(0, -73+dropDown, self.view.width, self.view.height)];
    }];
    _coverView = [[UIView alloc]initWithFrame:self.view.frame];
    [_coverView setBackgroundColor:[THMangerTool getRZColor:250 green:250 blue:250 alpha:0.1]];
    [self.view addSubview:_coverView];
    if (!showPop) {
        StockPopVIewController *popView = [[StockPopVIewController alloc]init];
        popView.delegate = self;
        popView.popViewArr = customerArr;
        [popView.view setFrame:CGRectMake(customerText.origin.x-5, 108, customerText.width, 222)];
        [_coverView addSubview:popView.view];
        _popView = popView;
        showPop = YES;
    }
}
//查询按钮

- (void)queryBut {
    if ([startStr isEqualToString:@""] || [endStr isEqualToString:@""]) {
        [[BDHUD sharedManager] showWords:[UtilCheck language:@"order.starttimeandendtime"]];
    }else {
        [stockDic setValue:startStr forKey:@"startTime"];
        [stockDic setValue:endStr forKey:@"endTime"];
        [stockDic setValue:[THMangerTool getKey] forKey:@"key"];
        [stockDic setValue:customerStr forKey:@"customer"];
        [stockDic setValue:attachmentNameBut.text forKey:@"plateName"];
        [stockDic setValue:attachmentBut.text forKey:@"plateCode"];
        [stockDic setValue:serialNumberBut.text forKey:@"plateSerial"];
        
        // 是否包含汉字
        if ([self checkIsChinese:[stockDic objectForKey:@"storeCode"]]==YES) {
            for (NSDictionary *dic in stockArr) {
                NSArray  *storearr = [dic objectForKey:@"region"];
                for (NSDictionary *storedic in storearr) {
                    if ([[storedic objectForKey:@"storeName"]isEqualToString:[stockDic objectForKey:@"storeCode"]]) {
                        [stockDic setObject:[storedic objectForKey:@"storeCode"] forKey:@"storeCode"];
                    }
                }
            }
        }
        NSLog(@"%@",stockDic);
        [[BDHUD sharedManager] showBDHUD:self.view title:nil];
        [AFHttpTool postJsonDatawithUrl:@"shipmentReportEnquiry"  parameters:stockDic success:^(id responseObject) {
            NSLog(@"responseobject ----- %@",responseObject);
            [[BDHUD sharedManager] dismissHUD];
            if(1 == [[[responseObject objectForKey:@"head"] objectForKey:@"status"] intValue] && [[responseObject objectForKey:@"data"] isKindOfClass:[NSArray class]]) {
                NSMutableArray *totalArr = [responseObject objectForKey:@"data"];
                if ([[responseObject objectForKey:@"teger"] integerValue] == 0) {
                    WarehouseTotalVC *vc = [[WarehouseTotalVC alloc]init];
                    vc.totalArr = totalArr;
                    vc.totalDic = stockDic;
                    vc.stockStr = [responseObject objectForKey:@"count"];
                    [self presentViewController:vc animated:YES completion:nil];
                }else {
                    SerialNumberVC *vc = [[SerialNumberVC alloc]init];
                    vc.numberArr = totalArr;
                    [self presentViewController:vc animated:YES completion:nil];
                }
            }
            else {
                //返回数据出问题 弹出服务器返回信息
                if([[[responseObject objectForKey:@"head"] allKeys] containsObject:@"info"]&&![UtilCheck DataIsNuLL:[[responseObject objectForKey:@"head"] objectForKey:@"info"]]){
                    [[BDHUD sharedManager] showWords:[[responseObject objectForKey:@"head"] objectForKey:@"info"]];
                }
            }
        } fail:^(id responseObject, NSError *error) {
            NSLog(@"%@",error);
            [[BDHUD sharedManager] dismissHUD];
            if ([[error.userInfo objectForKey:@"NSLocalizedDescription"] isEqualToString:@"请求超时。"]) {
                [[BDHUD sharedManager] showWords:[UtilCheck language:@"order.time.out"]];
            }else {
                [[BDHUD sharedManager] showWords:[UtilCheck language:@"order.network.interruption"]];
            }
        }];
    }
}

- (BOOL)checkIsChinese:(NSString *)string{
    for (int i=0; i<string.length; i++) {
        unichar ch = [string characterAtIndex:i];
        if (0x4E00 <= ch  && ch <= 0x9FA5) {
            return YES;
        }
    }
    return NO;
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [UIView animateWithDuration:0.5 animations:^{
        [queryView setFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
        if (showPop == YES) {
            [_coverView removeFromSuperview];
            [_popView.view removeFromSuperview];
            [_popView removeFromParentViewController];
            showPop = NO;
        }
    }];
}

//返回上个页面
- (void)backView {
    AppDelegate * app = [UIApplication sharedApplication].delegate;
    app.shouldChangeOrientation = NO;
    [self dismissViewControllerAnimated:YES completion:nil];
}
//选择时间
- (void)choiceTime {
    UIView *maskView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, queryView.bounds.size.width, self.view.height*2)];
    maskView.backgroundColor = [UIColor whiteColor];
    maskView.alpha = 0.2f;
    self.maskView = maskView;
    [queryView addSubview:self.maskView];
    
    //设置选择时间的TextField
    datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 150, self.view.frame.size.width, 150)];
    datePicker.backgroundColor = [UIColor whiteColor];
    datePicker.datePickerMode = UIDatePickerModeDate;
    datePicker.locale = [[NSLocale alloc] initWithLocaleIdentifier:[UtilCheck language:@"datePicker.LocalID"]];
    
    toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 150 - 44, self.view.frame.size.width, 44.0f)];
    toolBar.backgroundColor = [UIColor grayColor];
    UIBarButtonItem* leftItem = [[UIBarButtonItem alloc] initWithTitle:[UtilCheck language:@"button.cancel"] style:UIBarButtonItemStyleDone target:self action:@selector(cancelAction)];
    UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
    UIBarButtonItem* rightItem = [[UIBarButtonItem alloc] initWithTitle:[UtilCheck language:@"button.done"] style:UIBarButtonItemStyleDone target:self action:@selector(confirmAction:)];
    [toolBar setItems:@[leftItem,flexSpace,rightItem]];
    [self.view addSubview:datePicker];
    [self.view addSubview:toolBar];

}
- (void)cancelAction {
    [self.maskView removeFromSuperview];
    [datePicker removeFromSuperview];
    [toolBar removeFromSuperview];
}
- (void)confirmAction:(UIBarButtonItem *)item {
    [self.maskView removeFromSuperview];
    [datePicker removeFromSuperview];
    [toolBar removeFromSuperview];
    
    NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"yyyy-MM-dd";
    //选择时间不能大于当前时间
//    NSDate *selectedDate = datePicker.date;
//    NSDate *nowDate = [NSDate date];
//    if ([selectedDate earlierDate:nowDate] == selectedDate ) {
//        [Toolobject showTextWithMessage:[UtilCheck language:@"datePicker.noBeforeNow"]]; //@"选择的时间不能早于当前时间"
//        return;
//    }
    
    NSString *dateStr = [formatter stringFromDate:datePicker.date];
    if (teger == 101) {
        [startBut setTitle:dateStr forState:(UIControlStateNormal)];
        [startBut setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
        startStr = dateStr;
    }else {
        [endBut setTitle:dateStr forState:(UIControlStateNormal)];
        [endBut setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
        endStr = dateStr;
    }
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    dropDown = scrollView.contentOffset.y;
}
- (void)didSelectPopCellTwo:(NSInteger)row setArr:(NSMutableArray *)arr{
    
    [UIView animateWithDuration:0.5 animations:^{
        [queryView setFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
    }];
    [_coverView removeFromSuperview];
    [_popView.view removeFromSuperview];
    _popView = nil;
    showPop = NO;
    [customerText setTitle:arr[row] forState:(UIControlStateNormal)];
    [customerText setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    customerStr = arr[row];
    
    
}
- (void)didSelectPopCellTwo:(NSInteger)row setArr:(NSMutableArray *)arr strTager:(NSString *)tegerStr{
    [UIView animateWithDuration:0.5 animations:^{
        [queryView setFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
    }];
    [_coverView removeFromSuperview];
    [_popView.view removeFromSuperview];
    _popView = nil;
    showPop = NO;
    if ([tegerStr isEqualToString:@"1"]) {
        [warehouseBut setTitle:arr[row] forState:(UIControlStateNormal)];
        [warehouseBut setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
        [stockDic setValue:arr[row] forKey:@"storeCode"];
    }else {
        [warehouseBut setTitle:arr[row][@"storeName"] forState:(UIControlStateNormal)];
        [warehouseBut setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
        [stockDic setValue:arr[row][@"storeName"] forKey:@"storeCode"];
    }
    
}
- (void)didSelectPopCellTwo:(NSInteger)row setCodeArr:(NSMutableArray *)arr strTager:(NSString *)tegerStr{
    if ([tegerStr isEqualToString:@"1"]) {
        [stockDic setValue:arr[row] forKey:@"storeCode"];
    }else {
        [stockDic setValue:arr[row][@"storeCode"] forKey:@"storeCode"];
    }
    
}
#pragma mark - 获取仓库名信息
- (void)stockInquiry {
    NSMutableDictionary *stockDictionary = [NSMutableDictionary dictionaryWithCapacity:0];
    [stockDictionary setValue:[THMangerTool getKey] forKey:@"key"];
    [AFHttpTool postJsonDatawithUrl:@"inventoryForStoreName" parameters:stockDictionary success:^(id responseObject) {
    
        if (1 == [[[responseObject objectForKey:@"head"] objectForKey:@"status"] intValue]) {
            stockArr = [responseObject objectForKey:@"data"];
        }
    } fail:^(id responseObject, NSError *error) {
        if ([[error.userInfo objectForKey:@"NSLocalizedDescription"] isEqualToString:@"请求超时。"]) {
            [[BDHUD sharedManager] showWords:[UtilCheck language:@"order.time.out"]];
        }else {
            [[BDHUD sharedManager] showWords:[UtilCheck language:@"order.network.interruption"]];
        }
    }];
}

- (void)customerName {
    NSMutableDictionary *stockDictionary = [NSMutableDictionary dictionaryWithCapacity:0];
    [stockDictionary setValue:[THMangerTool getKey] forKey:@"key"];
    [AFHttpTool postJsonDatawithUrl:@"CustomerForStoreName" parameters:stockDictionary success:^(id responseObject) {
        
        if (1 == [[[responseObject objectForKey:@"head"] objectForKey:@"status"] intValue]) {
            customerArr = [responseObject objectForKey:@"data"];
        }
    } fail:^(id responseObject, NSError *error) {
        if ([[error.userInfo objectForKey:@"NSLocalizedDescription"] isEqualToString:@"请求超时。"]) {
            [[BDHUD sharedManager] showWords:[UtilCheck language:@"order.time.out"]];
        }else {
            [[BDHUD sharedManager] showWords:[UtilCheck language:@"order.network.interruption"]];
        }
    }];
}
@end
